package com.ruoyi.project.countrybus.controller;

import com.ruoyi.framework.web.controller.BaseController;
import com.ruoyi.project.countrybus.domain.SysAllInfo;
import com.ruoyi.project.countrybus.domain.SysCustomer;
import com.ruoyi.project.countrybus.domain.SysStation;
import com.ruoyi.project.countrybus.domain.SysStationRoute;
import com.ruoyi.project.countrybus.service.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

//@Api("allinfo")
@RestController
@RequestMapping("/AllInfoPerDispatch")
public class SysAllInfoController extends BaseController {

    @Autowired
    private ISysDispatchService iSysDispatchService;

    @Autowired
    private ISysVehicleService iSysVehicleService;

    @Autowired
    private ISysDriverService iSysDriverService;

    @Autowired
    private ISysStationService iSysStationService;

    @Autowired
    private ISysStationRouteService iSysStationRouteService;

    @Autowired
    private ISysCustomerService iSysCustomerService;

    @Autowired
    private ISysDispatchCustomerService iSysDispatchCustomerService;

    SysAllInfo sysAllInfo = new SysAllInfo();

//    @ApiOperation("allinfotest")
    @GetMapping(value = "/{dispatchId}")
    public SysAllInfo getInfo(@PathVariable("dispatchId") Long dispatchId){

        sysAllInfo.setSysDispatch(iSysDispatchService.selectSysDispatchByDispatchId(dispatchId));
        sysAllInfo.setSysVehicle(iSysVehicleService.selectSysVehicleByVehicleId(sysAllInfo.getSysDispatch().getVehicleId()));
        sysAllInfo.setSysDriver(iSysDriverService.selectSysDriverByDriverId(sysAllInfo.getSysVehicle().getDriverId()));
//        sysAllInfo.setSysStationRouteList(iSysStationRouteService.selectSysStationRouteByRouteId(sysAllInfo.getSysDispatch().getRouteId()));
//
//        List<SysStation> list = null;
//        for (SysStationRoute sysStationRoute : sysAllInfo.getSysStationRouteList()) {
//            list.add(iSysStationService.selectSysStationByStationId(sysStationRoute.getStationId()));
//        }
//        sysAllInfo.setSysStationList(list);
//
//        List<SysCustomer> listC = null;
//        SysDispatchCustomer sysDispatchCustomerC = new SysDispatchCustomer();
//        sysDispatchCustomerC.setRouteId(sysAllInfo.getSysDispatch().getRouteId());
//        for (SysDispatchCustomer sysDispatchCustomer : iSysDispatchCustomerService.selectSysDispatchCustomerList(sysDispatchCustomerC)) {
//            listC.add(iSysCustomerService.selectSysCustomerByCustomerId(sysDispatchCustomer.getCustomerId()));
//        }
//        sysAllInfo.setSysCustomerList(listC);
//        System.out.println("11111111111111111111111");
        return sysAllInfo;
    }

}
